package cn.oa.service.impl;

import cn.oa.dao.impl.PositionDaoImpl;
import cn.oa.entity.Position;
import cn.oa.service.PositionService;
import cn.oa.util.DatabaseUtil;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

public class PositionServiceImpl implements PositionService {
    @Override
    public List<Position> getAllPositions() throws SQLException {
        Connection conn = null;
        try{
            conn  = DatabaseUtil.getConnection();
            return new PositionDaoImpl(conn).getAllPositions();
        }catch(SQLException e){
            e.printStackTrace();
            throw e;
        }finally{
            DatabaseUtil.closeAll(conn,null,null);
        }
    }
}
